﻿using System;
using System.Collections.Generic;
using System.Text;

using com.tiyma.model;

namespace com.tiyma.common
{
    public class Consts
    {
        /// <summary>
        /// 成功的
        /// </summary>
        public const int Successed = 0;

        /// <summary>
        /// 失败的
        /// </summary>
        public const int Failed = -1;

        public const string VifCode = "yc@!78k";

        public static DateTime MinValue = new DateTime(1954, 1, 1);

        public static DateTime MaxValue = new DateTime(9999, 1, 1);

        public static int qidian = 21;

        public static int qdmm = 22;

        public static int zongheng = 25;

        /// <summary>
        /// 小说章节存在章节内容
        /// </summary>
        public static int ExistChapterContent = 1;

        /// <summary>
        /// 章节地址
        /// </summary>
        public static string ChapterPath = "/chaptertxt/{0}/txt/{1}.txt";
        /// <summary>
        /// 章节中的图片地址
        /// </summary>
        public static string PicPath = "/chaptertxt/{0}/pic/{1}/";

        /// <summary>
        /// 有封面
        /// </summary>
        public static int ExistsICON = 2;

        public enum SearchType
        {
            /// <summary>
            /// 书名
            /// </summary>
            BookName=1,
            /// <summary>
            /// 作者
            /// </summary>
            AuthorName=2,
            /// <summary>
            /// 类别
            /// </summary>
            Category=3,
            /// <summary>
            /// 综合
            /// </summary>
            General=4
        }

        /// <summary>
        /// 操作结果
        /// </summary>
        public  enum ResultType
        {
            /// <summary>
            /// 已经存在
            /// </summary>
            Exists=0,
            /// <summary>
            /// 成功
            /// </summary>
            Successed=1,
            /// <summary>
            /// 失败
            /// </summary>
            Faild=2
        }

        /// <summary>
        /// 站点
        /// </summary>
        public enum Site
        {
            /// <summary>
            /// 起点
            /// </summary>
            qidian = 1,
            /// <summary>
            /// 起点女生频道
            /// </summary>
            qdmm = 2,
            /// <summary>
            /// 晋江文学城
            /// </summary>
            jjwxc = 3,
            /// <summary>
            /// 17k小说
            /// </summary>
            yqk = 4,
            /// <summary>
            /// 小说阅读
            /// </summary>
            readnovel = 5,
            /// <summary>
            /// 来文学小说网
            /// </summary>
            laiwx = 6,
            /// <summary>
            /// 闪舞小说
            /// </summary>
            swxs = 7,
            /// <summary>
            /// 千载中文网
            /// </summary>
            qianzai = 8
        }

        /// <summary>
        /// 章节类别
        /// </summary>
        public enum ChapterType
        {
            chapter,
            reader,
        }

        private static List<SiteInfo> GetSiteList()
        {

            List<SiteInfo> t_list = new List<SiteInfo>();

            SiteInfo t_site = new SiteInfo();
            t_site.SiteId = 6;
            t_site.SiteName = "万书吧";
            t_site.SiteDomin = "www.wanshuba.com";
            t_list.Add(t_site);

            t_site = new SiteInfo();
            t_site.SiteId = 5;
            t_site.SiteName = "第就中文";
            t_site.SiteDomin = "d9cn.org";
            t_list.Add(t_site);

            t_site = new SiteInfo();
            t_site.SiteId = 15;
            t_site.SiteName = "热点文学";
            t_site.SiteDomin = "www.rdnovel.com";
            t_list.Add(t_site);

            t_site = new SiteInfo();
            t_site.SiteId = 20;
            t_site.SiteName = "明书楼";
            t_site.SiteDomin = "www.mingshulou.com";
            t_list.Add(t_site);


           
            return t_list;
        }

        public static int GetSiteId(string i_chapter_url)
        {
            List<SiteInfo> t_list = GetSiteList();

            int t_site_id = 0;
            foreach (SiteInfo t_site in t_list)
            {
                if (i_chapter_url.ToLower().IndexOf(t_site.SiteDomin)>-1)
                {
                    t_site_id = t_site.SiteId;
                    break;
                }
            }

            return t_site_id;
        }

      

        /// <summary>
        /// 获取章节表名
        /// </summary>
        /// <param name="i_site_id"></param>
        /// <returns></returns>
        public static string GetTableName(int i_site_id)
        {
            List<SiteInfo> t_list = GetSiteList();

            string t_table_name = string.Empty;

            foreach (SiteInfo t_site in t_list)
            {
                if (t_site.SiteId == i_site_id)
                {
                    t_table_name = t_site.TableName;
                    break;
                }
            }

            return t_table_name;
        }

        /// <summary>
        /// 获取站点名称
        /// </summary>
        /// <param name="i_site_id"></param>
        /// <returns></returns>
        public static string GetSiteName(int i_site_id)
        {
            List<SiteInfo> t_list = GetSiteList();

            string t_site_name = string.Empty;

            foreach (SiteInfo t_site in t_list)
            {
                if (t_site.SiteId == i_site_id)
                {
                    t_site_name = t_site.SiteName;
                    break;
                }
            }

            return t_site_name;
        }

      
    }
}
